package org.analyzer.ansj;

import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.core.StopFilter;
import org.apache.lucene.analysis.util.CharArraySet;
import org.apache.lucene.analysis.util.StopwordAnalyzerBase;

import java.io.Reader;

public final class AnsjAnalyzer extends StopwordAnalyzerBase {

    public AnsjAnalyzer() {
        super(CharArraySet.EMPTY_SET);
    }

    public AnsjAnalyzer(CharArraySet stopwords) {
        super(stopwords);
    }

    @Override
    protected TokenStreamComponents createComponents(String fieldName,
                                                     Reader reader) {
        final Tokenizer source = new AnsjTokenizer(reader, 1, true);
        return new TokenStreamComponents(source, new StopFilter(getVersion(), source, stopwords));

    }
}